<?php
include("includes/rss_php.php");
include("includes/myconnect.php");
if(count($argv) < 0) exit();
$curLink = $argv[1];
$rss = new rss_php;
$rss->load($curLink);
$items = $rss->getItems();
$strPattern = '/([A-z]{3}) *= *([A-z]{3}) *\(([\d]*,*[\d]+\.[\d]+)\)/';
$arrOut = array();
$sql_query = "INSERT INTO tblCurrencyExchangerate(currencyRootId,currencyReferId,exchangeRate) VALUES ";
foreach ($items as $item)
{
    preg_match($strPattern, $item['title'], $arrOut);

    if (is_array($arrOut))
    {
        $currencyRootId = $arrOut[1];
        $currencyReferId = $arrOut[2];
        $exchangeRate = $arrOut[3];

        $sql_query .= " ('" . $currencyRootId . "','" . $currencyReferId . "','" . $exchangeRate .
            "'),";
        //echo $sql_query			. "<br>";
    }
}
$sql_query = substr($sql_query, 0, strlen($sql_query) - 1);
mysql_query($sql_query) or die(mysql_error());

?>